# -*- coding:utf-8 -*—

import threading
import time


def worker(num):
    """线程工作函数"""
    print(f"Thread {num} starting.")
    time.sleep(2)
    print(f"Thread {num} finished.")


def main():
    """主程序，创建并启动线程"""
    threads = []
    for i in range(3):  # 创建并启动3个线程
        t = threading.Thread(target=worker, args=(i,))
        threads.append(t)
        t.start()

    for t in threads:
        t.join()  # 等待所有线程完成


if __name__ == "__main__":
    main()